import { Dispatch } from 'redux';
import { ArticleSummaryModel } from '../../../models/articleSummaryModel';
import { getHomeArticleList } from '../../../utils/apiUtil'
import { HomeArticleListAction } from './homeArticleList';

export const setHomeArticleList = (payload: ArticleSummaryModel[]): HomeArticleListAction => {
    return {
        type: 'SET_HOMEARTICLELIST',
        payload: payload
    }
}

export const setHomeArticleListAsync = (type: string) => (dispatch: Dispatch) => {
    getHomeArticleList(type).then(res => {
        dispatch(setHomeArticleList(res));
    });
}